<template>
	<view>
		<text style="font-size: 28px;">对这次菜品的满意程度：</text>
		<u-rate  @change="c" size="30" style="margin-top: 20px;"></u-rate>
		<view class="c1">
			<textarea placeholder="请输入评价内容" v-model="value"></textarea>
		</view>
		<u-button type="primary" text="提交" style="width: 100px;" @click="addcomment"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				count:1,
				value:'',
				order:''
			}
		},
		onLoad(options) {
			this.order=options.order
		},
		methods: {
			c(e){
				this.count=e
				console.log(this.count)
			},
			addcomment(){
				if(this.value===''){
					uni.showToast({
						title:'内容为空',
						icon:'error'
					})
					return
				}
				const data={
					content:this.value,
					orderNo:this.order,
					score:this.count
				}
				this.api.get('/prod-api/api/takeout/comment','POST',data).then(res=>{
					if(res.data.code===200){
						setTimeout(function(){
							uni.showToast({
								title:'评价成功'
							})
						},700)
						uni.redirectTo({
							url:'/pages/other/takaway/indent/indentdetail/indentdetail?order='+this.order
						})
					}else{
						console.log(res.data)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.c1{
	width: 300px;
	border: 2px solid #ccc;
	margin: 20px auto;
}
</style>
